﻿namespace ctolua.Models
{
    /// <summary>
    /// 投掷物
    /// </summary>
    public class MProjectile
    {
        /// <summary>
        /// 投掷物
        /// </summary>
        public ProjectileEntity projectile { get; set; }
        /// <summary>
        /// 投射物编号
        /// </summary>
        /// <returns>投射物的key</returns>
        public int? key => this.projectile.api_get_key();
        /// <summary>
        /// 投射物所属单位
        /// </summary>
        public Unit owner
        {
            get => this.projectile.api_get_owner();
            set => game_api.change_projectile_owner(this.projectile, value);
        }
        /// <summary>
        /// 投射物所属技能
        /// </summary>
        public Ability MyProperty
        {

            set => game_api.change_projectile_ability(this.projectile, value);
        }

        /// <summary>
        /// 投射物名称
        /// </summary>
        public string name => game_api.get_projectile_name_by_type(this.key);
        /// <summary>
        /// 描述
        /// </summary>
        public string desc => game_api.get_projectile_desc_by_type(this.key);
        /// <summary>
        /// 是否存在
        /// </summary>
        public bool? is_null => game_api.projectile_is_exist(this.projectile);
        /// <summary>
        /// 最后创建的投射物
        /// </summary>
        public static MProjectile get_last_created_projectile => new MProjectile(game_api.get_last_created_projectile());
        public MProjectile(ProjectileEntity projectile)
        {
            this.projectile = projectile;
        }

        /// <summary>
        /// 在单位的挂接点创建一个投掷物
        /// </summary>
        /// <param name="p_key"> 投掷物编号 </param>
        /// <param name="socket_unit"> 挂节点所属单位 </param>
        /// <param name="socket_name"> 挂接点名称 </param>
        /// <param name="face"> 朝向 </param>
        /// <param name="owner_unit_or_player"> 所属单位或玩家 </param>
        /// <param name="related_ability"> 关联技能 </param>
        /// <param name="visibility"> 粒子特效可见性规则 </param>
        /// <param name="duration"> 持续时间 </param>
        /// <param name="is_open_duration"> 是否启用持续时间 </param>
        /// <param name="immediately"> 立即移除表现 </param>
        /// <param name="use_sys_d_destroy_way"> 特效删除的方式是否读表 </param>
        /// <returns>创建出的投掷物</returns>
        public MProjectile(int? p_key, Unit socket_unit, string socket_name, Fix32 face, dynamic owner_unit_or_player, Ability related_ability, int? visibility, Fix32 duration, bool? is_open_duration, bool? immediately, bool? use_sys_d_destroy_way)
        {
            this.projectile = game_api.create_projectile_on_socket(p_key, socket_unit, socket_name, face, owner_unit_or_player, related_ability, visibility, duration, is_open_duration, immediately, use_sys_d_destroy_way);
        }
        /// <summary>
        /// 创建一个投掷物
        /// </summary>
        /// <param name="p_key"> 投掷物编号 </param>
        /// <param name="location"> 位置 </param>
        /// <param name="face"> 朝向 </param>
        /// <param name="owner_unit_or_player"> 所属单位 </param>
        /// <param name="related_ability"> 关联技能 </param>
        /// <param name="duration"> 持续时间 </param>
        /// <param name="is_open_duration"> 是否启用持续时间 </param>
        /// <param name="height"> 高度 </param>
        /// <param name="visibility"> 粒子特效可见性规则 </param>
        /// <param name="immediately"> 立即移除表现 </param>
        /// <param name="use_sys_d_destroy_way"> 特效删除的方式是否读表 </param>
        /// <returns>创建出的投掷物</returns>
        public MProjectile(int? p_key, Point location, Fix32 face, Unit owner_unit_or_player, Ability related_ability, Fix32 duration, bool? is_open_duration, Fix32 height, int? visibility, bool? immediately, bool? use_sys_d_destroy_way)
        {
            this.projectile = game_api.create_projectile_in_scene(p_key, location, face, owner_unit_or_player, related_ability, duration, is_open_duration, height, visibility, immediately, use_sys_d_destroy_way);
        }
        /// <summary>
        /// 创建一个投掷物
        /// </summary>
        /// <param name="p_key"> 投掷物编号 </param>
        /// <param name="location"> 位置 </param>
        /// <param name="owner_unit_or_player"> 所属单位或玩家 </param>
        /// <param name="face"> 朝向 </param>
        /// <param name="related_ability"> 关联技能 </param>
        /// <param name="duration"> 持续时间 </param>
        /// <param name="is_open_duration"> 是否启用持续时间 </param>
        /// <param name="height"> 高度 </param>
        /// <param name="visibility"> 粒子特效可见性规则 </param>
        /// <param name="immediately"> 立即移除表现 </param>
        /// <param name="use_sys_d_destroy_way"> 特效删除的方式是否读表 </param>
        /// <returns>创建出的投掷物</returns>
        public MProjectile(int? p_key, Point location, dynamic owner_unit_or_player, Fix32 face, Ability related_ability, Fix32 duration, bool? is_open_duration, Fix32 height, int? visibility, bool? immediately, bool? use_sys_d_destroy_way)
        {
            this.projectile = game_api.create_projectile_in_scene_new(p_key, location, owner_unit_or_player, face, related_ability, duration, is_open_duration, height, visibility, immediately, use_sys_d_destroy_way);
        }
    }
}
